{{ $data := (newScratch) }}

{{ ($data.Add "suggestedAnswer" (slice)) }}
{{ with (.Resources.Match "answer.*.md") }}
    {{ range . }}
        {{ ($data.Add "suggestedAnswer" (dict
        "@type" "Answer"
        "text" ((.Plain) | chomp)
        "inLanguage" (partial "seo/schema/function/language" .)
        "url" (.Permalink)
        )) }}
    {{ end }}
{{ end }}

{{ $qapage := (dict
"@context" "https://schema.org"
"@type" "QAPage"
"mainEntity" (dict
"@type" "Question"
"name" (.Title)
"text" ((.Plain) | chomp)
"inLanguage" (partial "seo/schema/function/language" .)
"datePublished" (partial "seo/schema/function/date.published" .)
"dateCreated" (partial "seo/schema/function/date.created" .)
"dateModified" (partial "seo/schema/function/date.modified" .)
"keywords" (partial "seo/schema/function/keywords" .)
"answerCount" ((.Resources.Match "answer.*.md") | len)
"suggestedAnswer" ($data.Get "suggestedAnswer")
)
"publisher" (printf "%s%s" ("/" | absURL) ("#organization"))
) }}

<script type="application/ld+json">{{ ((($qapage) | jsonify) | safeJS) }}</script>
